# Contributor: Carlo Landmeter <clandmeter@alpinelinux.org>
# Contributor: Dermot Bradley <dermot_bradley@yahoo.com>
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=acct
pkgver=6.6.4
pkgrel=1
pkgdesc="The GNU Accounting Utilities"
url="https://www.gnu.org/software/acct/"
arch="all"
license="GPL-3.0-or-later"
makedepends="
	linux-headers
	"
options="!check" # compares build utils with host utils so may fail
subpackages="
	$pkgname-doc
	$pkgname-openrc
	"
source="
	https://ftp.gnu.org/gnu/acct/acct-$pkgver.tar.gz
	initd
	logrotate
	"

prepare() {
	default_prepare
	update_config_sub
	sed -i -e '/gets is a/d' \
		"$builddir"/lib/stdio.in.h

	# correct the path to the wtmp file
	sed -i -e 's|, WTMP_FILE|, "/var/log/wtmp"|' \
		configure
}

build() {
	# seems like this makefile does not respect DESTDIR
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--mandir="$pkgdir"/usr/share/man \
		--infodir="$pkgdir"/usr/share/info \
		--enable-linux-multiformat
	make LDADD="-lm lib/libgnu.la"
}

package() {
	make prefix="$pkgdir/usr" install

	# last is provided by util-linux-login
	rm "$pkgdir"/usr/bin/last "$pkgdir"/usr/share/man/man1/last.1

	install -m755 \
		-D \
		"$srcdir"/initd \
		"$pkgdir"/etc/init.d/acct

	install -m644 \
		-D \
		"$srcdir"/logrotate \
		"$pkgdir"/etc/logrotate.d/acct
}

sha512sums="
413aa446caece8fd773c92e2995bbaa034f63dd0ced521815a676c49f118e02982862b9c0ab7e60be5212c87d1e82ba6325bda212cf4857392a068d359a1e2c2  acct-6.6.4.tar.gz
ccde27aeb9e21199c151fdd528dc195aefe4919d61996cdaf5321d488210e727f09a8d65a01b07e5d4cbd69bdc2ed4e8b75538dbcf4e6464474ed3fb5b62f9a4  initd
4be87c186fc9898cc1d1096cfb37616954fd992cdb40f1dde8b5ddaf94794235015ea2bbd0fccd32f1f33798ea557186bb93d1da1c9105e8d328a6e2965d58fe  logrotate
"
